#include <iostream>
#include <cstring>
#include <cmath>
int main(){
	int g1,s1,k1,g2,s2,k2;
	scanf("%d.%d.%d",&g1,&s1,&k1);
	scanf("%d.%d.%d",&g2,&s2,&k2);
	int sum1=0,sum2=0,sum;
	sum1=(g1*17+s1)*29+k1;
	sum2=(g2*17+s2)*29+k2;
	sum=sum2-sum1;
	if(sum<0){
		printf("-");
		int t;
		t=sum1;
		sum1=sum2;
		sum2=t;
	}
	int g3,s3,k3;
	g3=sum/493;
	s3=(sum%493)/29;
	k3=sum%29;
	printf("%d.%d.%d",g3,s3,k3);
	return 0;
	
	
}
